/*
 * @Author: szx
 * @Date: 2021-10-22 12:53:57
 * @LastEditTime: 2021-10-22 14:08:20
 * @Description:
 * @FilePath: \leetcode\229\229.cpp
 */
#include <iostream>
#include <unordered_map>
#include <vector>
using namespace std;

class Solution {
   public:
    vector<int> majorityElement(vector<int>& nums) {
        int n = nums.size();
        vector<int> ans;
        unordered_map<int, int> cnt;

        for (auto & v : nums) {
            cnt[v]++;
        }
        for (auto & v : cnt) {
            if (v.second > n / 3) {
                ans.push_back(v.first);
            }
        }
        return ans;
    }
};

int main() {
    Solution s;
    // s.majorityElement();
    return 0;
}